console.log("sss");

// 未登录，跳转到登录界面
function adaptor_401(payload, response, api, context) {
    if (response.data.status == 401) {
        localStorage.clear();
        window.location.href = "/login"
    }
    return response.data;
}

return {
  "type": "page",
  "title": "列表",
  "remark": null,
  "name": "page-demo",
  "toolbar": [
    {
      "type": "button",
      "actionType": "link",
      "link": "/crud/new",
      "label": "新增",
      "primary": true
    }
  ],
  "body": [
    {
      "type": "crud",
      "name": "sample",
      "api": {
        "url": "${API_HOST}/api/test/?page=${page}&perPage=${perPage}&keywords=${keywords}",
        "method": "get",
        "adaptor": adaptor_401
      },
      "filter": {
        "title": "",
        "mode": "inline",
        "wrapWithPanel": false,
        "submitText": "",
        "controls": [
          {
            "type": "text",
            "name": "keywords",
            "placeholder": "通过关键字搜索",
            "addOn": {
              "label": "搜索",
              "type": "submit",
              "className": "btn-success"
            },
            "clearable": true
          }
        ],
        "className": "m-b-sm"
      },
      "bulkActions": [
        {
          "label": "批量修改",
          "type": "button",
          "actionType": "dialog",
          "level": "primary",
          "dialog": {
            "title": "批量编辑",
            "name": "sample-bulk-edit",
            "body": {
              "type": "form",
              "api": "${API_HOST}/api/test/",
              "controls": [
                {
                  "type": "text",
                  "name": "engine",
                  "label": "Engine"
                }
              ]
            }
          }
        },
        {
          "label": "批量删除",
          "type": "button",
          "level": "danger",
          "actionType": "ajax",
          "api": {
            "url": "${API_HOST}/api/test/$id",
            "method": "delete",
            "adaptor": adaptor_401
          },
          "confirmText": "确定要批量删除?"
        }
      ],
      "columns": [
        {
          "name": "engine",
          "label": "Rendering engine",
          "sortable": true
        },
        {
          "name": "id",
          "label": "ID",
          "width": 20,
          "sortable": true
        },
        {
          "name": "browser",
          "label": "Browser",
          "sortable": true
        },
        {
          "name": "platform",
          "label": "Platform(s)",
          "sortable": true
        },
        {
          "name": "version",
          "label": "Engine version"
        },
        {
          "name": "grade",
          "label": "CSS grade"
        },
        {
          "type": "operation",
          "label": "操作",
          "width": "",
          "buttons": [
            {
              "type": "button-group",
              "buttons": [
                {
                  "type": "button",
                  "label": "查看",
                  "level": "primary",
                  "actionType": "link",
                  "link": "/api/test/${id}"
                },
                {
                  "type": "button",
                  "label": "修改",
                  "level": "info",
                  "actionType": "link",
                  "link": "/api/test/${id}/edit"
                },
                {
                  "type": "button",
                  "label": "删除",
                  "level": "danger",
                  "actionType": "ajax",
                  "confirmText": "您确认要删除?",
                  "api": {
                    "url": "${API_HOST}/api/test/$id",
                    "method": "delete",
                    "adaptor": adaptor_401
                  }
                }
              ]
            }
          ],
          "placeholder": "-",
          "fixed": "right"
        }
      ],
      "affixHeader": true,
      "columnsTogglable": "auto",
      "placeholder": "暂无数据",
      "tableClassName": "table-db table-striped",
      "headerClassName": "crud-table-header",
      "footerClassName": "crud-table-footer",
      "toolbarClassName": "crud-table-toolbar",
      "combineNum": 0,
      "bodyClassName": "panel-default"
    }
  ]
}
